package com.chen.tools;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

import org.springframework.core.convert.converter.Converter;


public class SingToDateConverter implements Converter<String,Date> {
	private String dataPattern;
	
	
	public SingToDateConverter(String dataPattern){
		System.out.println("StringToDateConverter convert:" + dataPattern);
		this.dataPattern = dataPattern;
	}
	@Override
	public Date convert(String s) {
		Date date = null;
		try {
			date = new SimpleDateFormat(dataPattern).parse(s);
			System.out.println("convert date:" + date);
		} catch (ParseException e) {
			e.printStackTrace();
		}
		return date;
	}


}
